refactor: split up bridge quote validators#9413
Conversation
a3b1b6c to
86125be
Compare
6513b61 to
4092316
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2cdd2f6. Configure here.
| value: HexString, | ||
| data: HexString, | ||
| gasLimit: nullable(number()), | ||
| effectiveGas: optional(number()), |
There was a problem hiding this comment.
Loose hex validation accepts invalid trades
Medium Severity
Trade and intent fields now use a custom HexString pattern (0x plus any alphanumeric characters) instead of isStrictHexString and isValidHexAddress. Malformed to/from lengths and non-hex characters in value/data (and intent token addresses) can pass quote validation and reach downstream signing or submission.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 2cdd2f6. Configure here.
There was a problem hiding this comment.
This is intentional. Clients should use whatever the backend provides


Explanation
This PR splits up the
validators.tsfile for better readability and removes some unused fields/exportsReferences
Related to https://consensyssoftware.atlassian.net/browse/SWAPS-4546
Checklist
Note
Medium Risk
Touches quote/trade validation and public export paths across bridge flows; Step schema and hex validation changes could reject or shape API payloads differently than before, though behavior is largely covered by updated tests.
Overview
Splits the monolithic
utils/validators.tsinto focused modules undersrc/validators/(quote, trade, feature-flags, batch-sell, etc.) and rewires the controller, fetch layer, selectors, metrics, and package exports to import from those files—positioned in the changelog as prep for QuoteResponse V2.Validation and typing tweaks ride along with the move:
QuoteResponseSchemaV1is centralized inquote-response-v1.ts(with optionall1GasFeesInHexWei/nonEvmFeesInNativeon the struct), token list checks usevalidateBridgeAssetinstead ofvalidateSwapsTokenObject, and SSE quote failures log via newformatStructErrors(richerStructErrormessages; tests/snapshots updated).StepSchemais narrowed to action + optional src/dest assets (protocol/chain/amount fields dropped from the struct), with mock quotes trimmed to match. Trade type guards move tovalidators/trade;trade-utilsonly keepsextractTradeData.FeeTypegains NETWORK / RELAYER; quote objects can carry extra optional fields (e.g. slippage, protocols, wallet addresses). Several legacy types ontypes.tsare deprecated in favor of V2-oriented shapes.Reviewed by Cursor Bugbot for commit 2cdd2f6. Bugbot is set up for automated code reviews on this repo. Configure here.